package com.yiyi.credit.manage.sso.mapper;

import com.yiyi.credit.manage.sso.common.mapper.CommonMapper;
import com.yiyi.credit.manage.sso.common.page.Pagination;
import com.yiyi.credit.manage.sso.model.entity.Shop;
import org.apache.ibatis.annotations.*;


import java.util.List;
import java.util.Map;


public interface ShopMapper extends CommonMapper<Shop> {

    @SelectProvider(type = ShopSqlProvider.class, method = "queryForPage")
    List<Shop> getPageData(@Param("sname") String sname,
                           @Param("pagination") Pagination pagination);

    @SelectProvider(type = ShopSqlProvider.class, method = "queryCount")
    Long getCount(@Param("sname") String sname);

    @Insert("insert into shop (sname,creater,province,city) values (#{shop.sname},#{shop.creater},#{shop.province},#{shop.city})")
    void add(@Param("shop") Shop shop);

    @Select("select * from shop s where s.id = #{id}")
    Shop getShopById(@Param("id") long sid);

    @Update("update shop set sname = #{shop.sname},updater = #{shop.updater},province = #{shop.province},city = #{shop.city} where id = #{shop.id}")
    void updateShop(@Param("shop") Shop shop);

    @Delete("delete from shop where id = #{shop.id}")
    void deleteShop(@Param("shop") Shop shop);

    @Select("select id,sname from shop ")
    List<Map<Integer, String>> getAllShop();
}
